
<template>
	<!-- 添加弹框 -->
	<el-dialog title="分校课程管理添加管理" :visible.sync="dialogTableVisible" class="wrap" @close="cancel" :close-on-click-modal="false">
		<div class="input-block">
			<span>课程名称：</span>
			<el-input v-model="vkcmc" placeholder="请输入课程名称" icon="add" class="input"></el-input>
		</div>
		<div class="input-block">
			<span>是否启用：</span>
      <el-select v-model="vsfjs" class="input" >
          <el-option label="启用" value="Y"></el-option>
          <el-option label="禁用" value="N"></el-option>
      </el-select>
		</div>
		<div class="input-block">
			<span>价格：</span>
			<el-input v-model="vjg" placeholder="请输入价格" icon="add" class="input"></el-input>
		</div>
		<div class="input-block">
			<span>基础价格：</span>
			<el-input v-model="vjcjg" placeholder="请输入基础价格" icon="add" class="input"></el-input>
		</div>
		<div class="input-block">
			<span>课时：</span>
			<el-input v-model="vks" placeholder="请输入课时" icon="add" class="input"></el-input>
		</div>
		<el-button type="info" class="submit" @click="submit">保存</el-button>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		data() {
			return {
				vjg: '',
				vjcjg: '',
				vks: '',
				vkcmc: '',
				vsfjs: 'Y',
				dialogTableVisible: true
			}
		},
		methods: {
			submit() {
				//检测
				this.$store.state.loading = true;
			   if(!this.vjg) {
					this.$message.warning('请填写课程名称');
					this.$store.state.loading = false;
					return;
				}
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					jg: this.vjg,
					jcjg: this.vjcjg,
					ks: this.vks,
					kcmc: this.vkcmc,
					sfjs: this.vsfjs,
					yhid: logininfo.id,
					xxid:logininfo.xxid
				});
				//执行
				this.axios.post(this.$store.state.api + 'fxkc/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						} else {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						//this.$emit('close', { type: 'add', cancel: false });
						this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			}
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.input {
			width: 300px;
			display: inline-block;
		}
		.input-block span {
			display: inline-block;
			width: 70px;
			text-align: right;
		}
		.submit {
			width: 120px;
			display: block;
			margin: 0 auto;
			margin-top: 20px;
		}
	}
</style>
